<?php
require_once 'InfoManager21.php';

$infoManager = new InfoManager();
$infos = $infoManager->getInfos();
?>
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信息列表</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h2>信息列表</h2>
    <a href="add_info21.php" class="add-button">添加信息</a>
    <table>
        <thead>
            <tr>
                <th>ID</th>
                <th>姓名</th>
                <th>邮箱</th>
                <th>电话</th>
                <th>地址</th>
                <th>爱好</th>
                <th>添加时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($infos as $info) : ?>
                <tr>
                    <td><?php echo $info['id']; ?></td>
                    <td><?php echo $info['name']; ?></td>
                    <td><?php echo $info['email']; ?></td>
                    <td><?php echo $info['phone']; ?></td>
                    <td><?php echo $info['address']; ?></td>
                    <td><?php echo $info['hobby']; ?></td>
                    <td><?php echo $info['created_at']; ?></td>
                    <td>
                        <a href="edit_info21.php?id=<?php echo $info['id']; ?>" class="edit">修改</a>
                        <a href="delete_info21.php?id=<?php echo $info['id']; ?>" class="delete" onclick="return confirm('确定要删除吗？')">删除</a>
                    </td>
                </tr>
                <?php endforeach; ?>
        </tbody>
    </table>
</body>
</html>